/**
 * 
 */
package test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.UnmarshalException;
import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;

import fr.ema.arch3d.xoADL.configuration.DefaultConfiguration;


/**
 * class description
 * 
 * @version    version 22 oct. 2009
 * @author     Huaxi (Yulin) ZHANG
 */
public class HA {

    /**
     * Method description
     *
     * @param args
     */
    public static void main(String[] args) {
	// TODO Auto-generated method stub
	JAXBContext context;
	try {
	    context = JAXBContext.newInstance("fr.ema.arch3d.xoADL.configuration");

	    Unmarshaller unmarshaller;
		unmarshaller = context.createUnmarshaller();
		//unmarshaller.setValidating(true);

	    File file=new File("E://Yulin//Nime//Code//workspace//Arch3D-xoADL//src//main//java//test//testc.xml");
	   //"E://Yulin//Nime//Code//workspace//exampleJAXB//src//test//test11.xml"

	    JAXBElement o=(JAXBElement)unmarshaller.unmarshal(new FileInputStream(file)) ; 

	    //System.out.println(((JAXBElement)o).getName());
//	    Specification spec =(Specification)(((JAXBElement)o).getValue());
//	    System.out.println(spec.getName());
//	    Configuration spec =(Configuration)(((JAXBElement)o).getValue());
//	    System.out.println(spec.getComponentImplementations().getComponentImplementation().get(0).getComponentClass().getName());
	    
	    
	    System.out.println("heeeeeee");
//	    ObjectFactory objFactory = new ObjectFactory();
//	    DefaultConfiguration c1=new DefaultConfiguration();;
//	    Configuration.ComponentImplementations impls = objFactory.createConfigurationComponentImplementations();
//	    Configuration.ComponentImplementations.ComponentImplementation impl = objFactory.createConfigurationComponentImplementationsComponentImplementation();
//	    c1.setComponentImplementations(impls);
//	    ComponentClassImpl ca=new ComponentClassImpl();
//	    ca.setName("ca hahaha");
//	    impls.getComponentImplementation().add(impl);
//	    impl.setComponentClass(ca);
//	    impl.setComponentRoleName("cr hahaha");
//	    
//	    Marshaller marshaller = context.createMarshaller();
//	    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
//		    new Boolean(true));
//	    JAXBElement oo=new JAXBElement(new QName("http://ema.fr/arch3d/xoADL/xsd","configuration"),Configuration.class,c1);
//	    //o.setValue(c1);
//	    System.out.println(c1.getComponentImplementations());
//	    marshaller.marshal(oo,new FileOutputStream("testout.xml"));
	    
	    
	} catch( UnmarshalException ue ) {
	    System.out.println( ue );
	} catch( JAXBException je ) { 
	    je.printStackTrace();
	} catch( IOException ioe ) {
	    ioe.printStackTrace();
	}

    }

}
